/**
 * @description  访问统计
 * @author shenhong
 */
import React, { PureComponent } from 'react';
import { connect } from 'dva';
import { SecondHeaderC, XYHorizontalChartsC } from '../../../comps';
import style from './index.less';

class showEchartsFour extends PureComponent {
  constructor() {
    super();
    this.state = {};
  }
  componentDidMount() {
    const { dispatch, args } = this.props;
    dispatch({
      type: 'visitStatisticsM/getEchartsFour',
      payload: args,
    });
  }
  UNSAFE_componentWillReceiveProps(nextProps) {
    const { args, timeStamp } = nextProps;
    if (JSON.stringify(args) !== JSON.stringify(this.props.args) || timeStamp !== this.props.timeStamp) {
      const { dispatch } = this.props;
      dispatch({
        type: 'visitStatisticsM/save',
        payload: { getEchartsFour: { xaxislist: undefined, serieslist: undefined } },
      });
      dispatch({
        type: 'visitStatisticsM/getEchartsFour',
        payload: args,
      });
    }
  }

  render() {
    const {
      visitStatisticsM: { getEchartsFour },
    } = this.props;
    const yAxis = getEchartsFour.xaxislist;
    const series = getEchartsFour.serieslist;
    return (
      <div className={style.body_area}>
        <SecondHeaderC title='TOP10热点功能' />
        <div className='showEcharts2'>
          <XYHorizontalChartsC series={series} yAxis={yAxis} title='功能' height={460} />
        </div>
      </div>
    );
  }
}
export default connect(({ visitStatisticsM }) => ({
  visitStatisticsM,
}))(showEchartsFour);
